package UDP.translation;
import UDP.EchoServer.UdpEchoServer;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * 服务器
 */
public class UdpDictServer extends UdpEchoServer {

    private Map<String,String> map = new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);
        map.put("cat","小猫咪~");
        map.put("dog","小狗勾~");
        map.put("pig","小猪~");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"该词无法翻译!");
    }

    public static void main(String[] args) throws IOException {

        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
